package xyz.xtt.exchange.entity;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Objects;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * <p>
 * 资产用户设置表
 * </p>
 *
 * @author author
 * @since 2025-02-18
 */
@Builder
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("tbl_asset_user_config")
@ApiModel(value = "TblAssetUserConfig对象", description = "资产用户设置表")
public class TblAssetUserConfig implements Serializable {

	private static final long serialVersionUID = 1L;

	@ApiModelProperty(value = "主键")
	@TableId(value = "id", type = IdType.AUTO)
	private Long id;

	@ApiModelProperty(value = "操作人appuid")
	private Long uid;

	@ApiModelProperty(value = "资产id")
	private Long assetId;

	@ApiModelProperty(value = "公示期开始")
	private Long publicityPeriodStart;

	@ApiModelProperty(value = "公示期结束")
	private Long publicityPeriodEnd;

	@ApiModelProperty(value = "公示结果0完成1取消")
	private Integer publicityPeriodResult;

	@ApiModelProperty(value = "折扣")
	private BigDecimal discount;

	@ApiModelProperty(value = "预售结束时间")
	private Long preSellStart;

	@ApiModelProperty(value = "出售结束时间")
	private Long preSellEnd;

	@ApiModelProperty(value = "是否可公开可见0私密1公开")
	private Integer publiclyVisible;

	@ApiModelProperty(value = "逻辑删除标识0未删除1已删除")
	private Boolean isDel;

	@ApiModelProperty(value = "创建时间")
	private LocalDateTime crtTime;
	private LocalDateTime uptTime;

	@ApiModelProperty(value = "版本号售卖次数")
	private Long ver;

	/**
	 * 检查公示期
	 * 
	 * @return
	 */
	public boolean checkPublicityPeriodIsNull() {
		return Objects.isNull(publicityPeriodStart) || Objects.isNull(publicityPeriodEnd);
	}

	/**
	 * 当前时间是否在公示期
	 * 
	 * @return
	 */
	public boolean checkPublicityPeriod() {
		long curr = System.currentTimeMillis();
		return curr >= publicityPeriodStart.longValue() && curr < publicityPeriodEnd.longValue();
	}

}
